package com.lh_travel.lohas.activity.user;

import android.content.pm.PackageManager;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.ImageButton;
import android.widget.ListView;
import android.widget.TextView;

import com.lh_travel.lohas.R;
import com.lh_travel.lohas.base.api;
import com.lh_travel.lohas.base.baseActivity;
import com.lh_travel.lohas.domain.Comment;
import com.tamic.novate.Throwable;
import com.tamic.novate.callback.RxResultCallback;

public class AboutLohasActivity extends baseActivity {

    private Toolbar toolbar;
    private ImageButton img_back;
    private TextView tv_html;
    private TextView tv_version;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_about);
        findView();
        bindListner();
        ensureUI();

    }

    @Override
    public void findView() {
        toolbar = (Toolbar) findViewById(R.id.toolbar);
        img_back = (ImageButton) findViewById(R.id.img_back);

        tv_html = (TextView) findViewById(R.id.tv_html);
        tv_version = (TextView) findViewById(R.id.tv_version);

    }

    @Override
    public void bindListner() {
        img_back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }

    @Override
    public void ensureUI() {
        setSupportActionBar(toolbar);
        toolbar.setEnabled(true);

        new api(mContext).getBaseInfo("2", new RxResultCallback<Comment>() {
            @Override
            public void onNext(Object tag, int code, String message, Comment response) {

                tv_html.setText(response.content);

            }

            @Override
            public void onError(Object tag, Throwable e) {

            }

            @Override
            public void onCancel(Object tag, Throwable e) {

            }
        });

        tv_version.setText("APP版本:" + getVerName());

    }

    public String getVerName() {
        String verName = "";
        try {
            verName = mContext.getPackageManager().getPackageInfo(mContext.getPackageName(), 0).versionName;
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }
        return verName;
    }
}
